/*
day211
2020.3.26
*/ 
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

class Solution {
public:
    bool checkInclusion(string s1, string s2) {
    	int size1=s1.size();
    	int size2=s2.size();
    	if(size2<size1)
		{
			return false;
		 } 
    	int arr1[26]={0},arr2[26]={0};
		
		for(int i=0;i<size1;++i)
		{
			arr1[s1[i]-'a']++;
			arr2[s2[i]-'a']++;
		}
		
		if(test(arr1,arr2)) 
		{
			return true;
		}
		
		for(int i=1;i+size1<=size2;++i)
		{
			arr2[s2[i-1]-'a']--;
			arr2[s2[i+size1-1]-'a']++;
			if(test(arr1,arr2))
			{
				return true;
			}
			
		}
		return false;
    }
    
    bool test(int *arr1,int *arr2)
	{
		for(int i=0;i<26;++i)
		{
			if(arr1[i]!=arr2[i])
			{
				return false;
			}
		}
		return true;
	} 
};

int main()
{
	Solution s;
	string s1 = "ab" ,s2 = "eidbaooo";
	cout<<s.checkInclusion(s1,s2)<<endl;
	return 0;
}
